let ajaxTime = 0;


export const request = (params) => {
/* let header={...params.header};
if(params.url.includes("/my/")){
    header["Authorization"]=wx.getStorageSync("token");
} */


    ajaxTime++;
    const baseUrl = "https://api-hmugo-web.itheima.net/api/public/v1"
    return new Promise((resolve, reject) => {
        wx.showLoading({ title: "加载中", mask: true });

        wx.request({
            ...params,
            header:header,
            url: baseUrl + params.url,

            //成功回调
            success: (reslut) => {
                resolve(reslut.data.message);
            },
            //失败回调
            fail: (err) => {
                reject(err);
            },
            //完成回调
            complete: () => {
                ajaxTime--;
                if (ajaxTime === 0) {
                    wx.hideLoading();
                }
            }
        });
    })
}